<?php
$filearray = [
    '../app/api/controller/Alliance_old.php',//小程序主要控制器
    '../app/api/controller/Callback_old.php',
    '../app/api/controller/Coupon_old.php',
    '../app/api/controller/Door_old.php',
    '../app/api/controller/ErrorCode_old.php',
    '../app/api/controller/index_old.php',
    '../app/api/controller/Integral_old.php',
    '../app/api/controller/Levelnotify_old.php',
    '../app/api/controller/Meituan_old.php',
    '../app/api/controller/MeiTuanSession_old.php',
    '../app/api/controller/Order_old.php',
    '../app/api/controller/Paynotify_old.php',
    '../app/api/controller/Paynotifycard_old.php',
    '../app/api/controller/Paynotifycoupon_old.php',
    '../app/api/controller/Payrnotify_old.php',
    '../app/api/controller/Product_old.php',
    '../app/api/controller/Productnotify_old.php',
    '../app/api/controller/Recharge_old.php',
    '../app/api/controller/Rechargenotify_old.php',
    '../app/api/controller/Room_old.php',
    '../app/api/controller/Seat_old.php',
    '../app/api/controller/Seatnotify_old.php',
    '../app/api/controller/Sign_old.php',
    '../app/api/controller/Till_old.php',
    '../app/api/controller/Time_old.php',
    '../app/api/controller/User_old.php',
    '../app/api/controller/Wap_old.php',
    '../app/api/controller/Wecat_old.php',
    '../app/api/controller/WXBizDataCrypt_old.php',
    '../app/api/controller/Wxpay_old.php',
    '../app/adminmini/controller/Card_old.php',//门店主要控制器
    '../app/adminmini/controller/CardcouponOrder_old.php',
    '../app/adminmini/controller/Cash_old.php',
    '../app/adminmini/controller/Cleaning_old.php',
    '../app/adminmini/controller/Coupon_old.php',
    '../app/adminmini/controller/Course_old.php',
    '../app/adminmini/controller/Door_old.php',
    '../app/adminmini/controller/File_old.php',
    '../app/adminmini/controller/House_old.php',
    '../app/adminmini/controller/Index_old.php',
    '../app/adminmini/controller/Login_old.php',
    '../app/adminmini/controller/Make_old.php',
    '../app/adminmini/controller/Meituan_old.php',
    '../app/adminmini/controller/Meituanorder_old.php',
    '../app/adminmini/controller/Member_old.php',
    '../app/adminmini/controller/Memberlevel_old.php',
    '../app/adminmini/controller/Menu_old.php',
    '../app/adminmini/controller/Mqtt_old.php',
    '../app/adminmini/controller/One_old.php',
    '../app/adminmini/controller/Order_old.php',
    '../app/adminmini/controller/Pay_old.php',
    '../app/adminmini/controller/Pricecoupon_old.php',
    '../app/adminmini/controller/PricecouponOrder_old.php',
    '../app/adminmini/controller/Profit_old.php',
    '../app/adminmini/controller/Recharge_old.php',
    '../app/adminmini/controller/RechargeOrder_old.php',
    '../app/adminmini/controller/Region_old.php',
    '../app/adminmini/controller/Renewalorder_old.php',
    '../app/adminmini/controller/Role_old.php',
    '../app/adminmini/controller/Room_old.php',
    '../app/adminmini/controller/Seat_old.php',
    '../app/adminmini/controller/Seatorder_old.php',
    '../app/adminmini/controller/Setcabinet_old.php',
    '../app/adminmini/controller/Team_old.php',
    '../app/adminmini/controller/Trill_old.php',
    '../app/adminmini/controller/Trillorder_old.php',
    '../app/adminmini/controller/Two_old.php',
    '../app/admin/controller/index_old.php',//门店主要控制器



];
foreach ($filearray as $k => $v) {
    if($v!=''){
        encryption($v);
    }
}
function encryption($filename)
{
    $newfilename = implode('', explode('_old', $filename));
    $T_k1 = RandAbc(); //随机密匙1
    $T_k2 = RandAbc(); //随机密匙2
    $vstr = file_get_contents($filename);
    $v1 = base64_encode($vstr);
    $c = strtr($v1, $T_k1, $T_k2); //根据密匙替换对应字符。
    $c = $T_k1 . $T_k2 . $c;
    $q1 = "O00O0O";
    $q2 = "O0O000";
    $q3 = "O0OO00";
    $q4 = "OO0O00";
    $q5 = "OO0000";
    $q6 = "O00OO0";
    $s = '$' . $q6 . '=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$' . $q1 . '=$' . $q6 . '[3].$' . $q6 . '[6].$' . $q6 . '[33].$' . $q6 . '[30];$' . $q3 . '=$' . $q6 . '[33].$' . $q6 . '[10].$' . $q6 . '[24].$' . $q6 . '[10].$' . $q6 . '[24];$' . $q4 . '=$' . $q3 . '[0].$' . $q6 . '[18].$' . $q6 . '[3].$' . $q3 . '[0].$' . $q3 . '[1].$' . $q6 . '[24];$' . $q5 . '=$' . $q6 . '[7].$' . $q6 . '[13];$' . $q1 . '.=$' . $q6 . '[22].$' . $q6 . '[36].$' . $q6 . '[29].$' . $q6 . '[26].$' . $q6 . '[30].$' . $q6 . '[32].$' . $q6 . '[35].$' . $q6 . '[26].$' . $q6 . '[30];eval($' . $q1 . '("' . base64_encode('$' . $q2 . '="' . $c . '";eval(\'?>\'.$' . $q1 . '($' . $q3 . '($' . $q4 . '($' . $q2 . ',$' . $q5 . '*2),$' . $q4 . '($' . $q2 . ',$' . $q5 . ',$' . $q5 . '),$' . $q4 . '($' . $q2 . ',0,$' . $q5 . '))));') . '"));';
    $s = '<?php ' . "\n" . $s . "\n" . ' ?>';
//echo $s;
// 生成 加密后的PHP文件
    $fpp1 = fopen($newfilename, 'w');
    fwrite($fpp1, $s) or die($filename . '写文件错误');
}

function RandAbc($length = "")
{ // 返回随机字符串
    $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    return str_shuffle($str);
}

?>